﻿<UserControl x:Class="GW2PAO.Views.ZoneCompletion.ZoneItemView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:converters="clr-namespace:GW2PAO.Style.Converters"
             xmlns:core="clr-namespace:GW2PAO.PresentationCore;assembly=GW2PAO.PresentationCore"
             mc:Ignorable="d" d:DesignWidth="225"
             TextOptions.TextFormattingMode="Display">

    <UserControl.Resources>

        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../../Style/ResourceLibrary.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <converters:ZoneItemTypeImageSrcConverter x:Key="ItemTypeImgConverter" />
            <converters:TimespanConverter x:Key="TimeConverter" />

        </ResourceDictionary>

    </UserControl.Resources>

    <UserControl.ContextMenu>
        <ContextMenu>
            <MenuItem Header="Hide" Command="{Binding HideCommand}" />
            <Separator />
            <MenuItem Header="Copy Chat Code" Command="{Binding CopyChatCodeCommand}" />
        </ContextMenu>
    </UserControl.ContextMenu>

    <Border CornerRadius="0" Margin="0" Padding="10,0,5,0" BorderThickness="0,0,0,1">


        <Border.BorderBrush>
            <LinearGradientBrush Opacity="0.5">
                <GradientStop Color="#FFFFA500" Offset="0.5"/>
                <GradientStop Color="#00FFA500" Offset="1"/>
            </LinearGradientBrush>
        </Border.BorderBrush>

        <Border.Background>
            <SolidColorBrush Color="#01FFFFFF" />
        </Border.Background>

        <Grid Margin="0,5,0,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="25" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="25"/>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>


            <core:OutlinedTextBlock Grid.Row="0" Grid.RowSpan="1" Grid.Column="0" Grid.ColumnSpan="2"
                                    VerticalAlignment="Center"
                                    Fill="White"
                                    Stroke="Black" StrokeThickness="4" StrokeOpacity="0.75"
                                    FontSize="12" FontFamily="Gisha"
                                    Text="{Binding ItemName}">
                <core:OutlinedTextBlock.Style>
                    <Style TargetType="core:OutlinedTextBlock">
                        <Style.Triggers>
                            <Trigger Property="Text" Value="">
                                <Setter Property="Visibility" Value="Collapsed" />
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </core:OutlinedTextBlock.Style>
            </core:OutlinedTextBlock>

            <Grid Grid.Row="1" Grid.RowSpan="1" Grid.Column="0" Height="15">
                <Path HorizontalAlignment="Center" VerticalAlignment="Center"
                  Stretch="Uniform"
                  Stroke="Black" Fill="Orange"
                  StrokeThickness="1"
                  StrokeStartLineCap="Round"  StrokeEndLineCap="Round"
                  RenderTransformOrigin="0.5,0.5">
                    <Path.Data>
                        <PathGeometry FillRule="Nonzero">
                            <PathGeometry.Figures>
                                <PathFigure StartPoint="5,0">
                                    <LineSegment Point="10,10"/>
                                    <LineSegment Point="5,8" />
                                    <LineSegment Point="0,10"/>
                                    <LineSegment Point="5,0"/>
                                </PathFigure>
                            </PathGeometry.Figures>
                        </PathGeometry>
                    </Path.Data>
                    <Path.RenderTransform>
                        <RotateTransform Angle="{Binding DirectionFromPlayer}" />
                    </Path.RenderTransform>
                </Path>
            </Grid>

            <StackPanel Grid.Row="1" Grid.RowSpan="1" Grid.Column="1"
                        Margin="5,0,0,0"
                        Orientation="Horizontal"
                        HorizontalAlignment="Left">

                <core:OutlinedTextBlock Name="EventName"
                                    VerticalAlignment="Center"
                                    Text="Distance:  " />

                <core:OutlinedTextBlock VerticalAlignment="Center">
                    <core:OutlinedTextBlock.Style>
                        <Style TargetType="core:OutlinedTextBlock" BasedOn="{StaticResource {x:Type core:OutlinedTextBlock}}">
                            <Setter Property="Text" Value="{Binding DistanceFromPlayer}"/>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding UserSettings.DistanceUnits}" Value="TimeDistance">
                                    <Setter Property="Text" Value="{Binding DistanceFromPlayer, Converter={StaticResource TimeConverter}, ConverterParameter=true}"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </core:OutlinedTextBlock.Style>
                </core:OutlinedTextBlock>

                <core:OutlinedTextBlock VerticalAlignment="Center" HorizontalAlignment="Left">
                    <core:OutlinedTextBlock.Style>
                        <Style TargetType="core:OutlinedTextBlock" BasedOn="{StaticResource {x:Type core:OutlinedTextBlock}}">
                            <Setter Property="Text" Value=" ft"/>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding UserSettings.DistanceUnits}" Value="Meters">
                                    <Setter Property="Text" Value=" m"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding UserSettings.DistanceUnits}" Value="TimeDistance">
                                    <Setter Property="Text" Value=""/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </core:OutlinedTextBlock.Style>
                </core:OutlinedTextBlock>
            </StackPanel>

            <CheckBox Name="UnlockedIcon" Grid.Row="0" Grid.RowSpan="2" Grid.Column="2"
                      VerticalAlignment="Center" HorizontalAlignment="Center"
                      Margin="0,0,10,3"
                      IsChecked="{Binding IsUnlocked}">
                <CheckBox.Style>
                    <Style TargetType="{x:Type CheckBox}">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type CheckBox}">
                                    <Image MaxHeight="20" MaxWidth="20">
                                        <Image.Source>
                                            <MultiBinding Converter="{StaticResource ItemTypeImgConverter}">
                                                <Binding Path="ItemType"/>
                                                <Binding Path="IsUnlocked"/>
                                            </MultiBinding>
                                        </Image.Source>
                                    </Image>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                        <Setter Property="Effect">
                            <Setter.Value>
                                <DropShadowEffect ShadowDepth="0"
                                              Color="Gold"
                                              Opacity="0"
                                              BlurRadius="15"/>
                            </Setter.Value>
                        </Setter>
                        <Style.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Trigger.EnterActions>
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <DoubleAnimation To="1"
                                                         Storyboard.TargetProperty="(Effect).Opacity"
                                                         Duration="00:00:00.1"/>
                                        </Storyboard>
                                    </BeginStoryboard>
                                </Trigger.EnterActions>
                                <Trigger.ExitActions>
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <DoubleAnimation To="0"
                                                         Storyboard.TargetProperty="(Effect).Opacity"
                                                         Duration="00:00:0.1"/>
                                        </Storyboard>
                                    </BeginStoryboard>
                                </Trigger.ExitActions>
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </CheckBox.Style>
            </CheckBox>

        </Grid>
    </Border>
</UserControl>
